Skip to content

Conversation

@donncha
Copy link

@donncha donncha commented Feb 28, 2023

Discovered that connection flags were not being passed to the client with Rails.

The flag parsing in Mysql2::Client first checks if the constant is defined before setting the flag, and this was failing as the original client had been swapped out, leading to the odd situation where you could see the value of the constant, but it was saying it wasn't defined.

irb> Mysql2::Client.const_get("MULTI_STATEMENTS")
=> 65536
irb> Mysql2::Client.const_defined?("MULTI_STATEMENTS")
=> true

Solution is to also delegate const_defined? to the origin client.

@vladimir-mencl-eresearch

Hi,

I'm running into the same issue in projects setting ssl_mode connection parameter.

The Mysql2::Client first checks the ssl_mode value with const_defined? before resolving it with Client.const_get:

return Mysql2::Client.const_get(m) if Mysql2::Client.const_defined?(m)

... and so it ends up evaluating all ssl_mode values as invalid.

This PR would solve it - @alfa-jpn , would you please consider merging it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants